var app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    hasUserInfo: false,//是否登录
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    state:'',
    smTeller:{},
    msg:'',
    errorMsg:'',
    showModalStatus: false,
    grids: [
      // {
      //     imgUrl: "../../images/5.png",
      //     url: "",
      //     text: '账号信息'
      // },
      {
          imgUrl: "../../images/6.png",
          url: "",
          text: '个人客户'
      },
      {
          imgUrl: "../../images/7.png",
          url: "",
          text: '企业客户'
      },
      {
          imgUrl: "../../images/8.png",
          url: "",
          text: '设置'
      }
    ],
    gridss: [
      // {
      //     imgUrl: "../../images/5.png",
      //     url: "../userConsole/userConsole",
      //     text: '账号信息'
      // },
      {
          imgUrl: "../../images/6.png",
          url: "../customer/personal/personal",
          text: '个人客户'
      },
      {
          imgUrl: "../../images/7.png",
          url: "",
          text: '企业客户'
      },
      {
          imgUrl: "../../images/8.png",
          url: "../up/up",
          text: '设置'
      }
    ]
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    var that = this;
     var pages = getCurrentPages();
     var currPage = pages[pages.length - 1]; //当前页面
     if(currPage.data.state == "1")
     {
      currPage.data.state = '';
      that.data.smTeller = currPage.data.smTeller;
        wx.showToast({
          title: currPage.data.msg,
          icon: 'loading',
          duration: 1500
        });
        wx.getUserInfo({
          success: function(res) {
            that.setData({
              userInfo : res.userInfo,
              hasUserInfo :true
            })
          }
        })
     }
     else if(currPage.data.state == "2")
     {
        currPage.data.state = '';
        wx.showToast({
          title: currPage.data.msg,
          icon: 'loading',
          duration: 1500
        })
     }
     else if(currPage.data.state == "3"){
        currPage.data.state = '';
        wx.showToast({
          title: currPage.data.msg,
          icon: 'loading',
          duration: 1500
        })
        this.outLogo();
     }
  },
  bindGetUserInfo: function(e){
    if (e.detail.userInfo) {
      //用户按了允许授权按钮
      wx.navigateTo({
        url: '../login/index'
      })
    }
    else
    {
      wx.showModal({
        title:'警告',
        content:'您拒绝授权，将无法进入，请授权之后再进入!!!',
        showCancel:false,
        confirmText:'返回授权',
        success:function(res){
            
        }
      })
    }
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },
  outLogo: function(){
    var that = this;
    that.setData({
      hasUserInfo :false
    })
  },
  showMustBeLogin(){
    this.setData({errorMsg:'请先登录'})
  }
})